#include "rbtree.hpp"
#include<vector>

int main()
{
	// insert & search test
	{
		cout << "=============" << "insert & search test" << "=============" << endl;
		vector<int> nums{ 10,40,30,60,90,70,20,50,65,80,100 };
		RBTree<int> tree;
		for (auto num : nums)
		{
			tree.insert(num);
			tree.Order(MidOrder);
		}

		tree.Order(PreOrder);

		tree.Order(PostOrder);

		cout << "find 30:\n";
		cout << tree.search(30)->key << endl << endl;
	}

	// delete test
	{
		cout << "=============" << "delete test" << "=============" << endl;
		vector<int> nums{ 10,40,30,60 }; //,90,70,20,50,65,80,100 };
		RBTree<int> tree;
		for (auto num : nums)
		{
			tree.insert(num);
			tree.Order(MidOrder);
		}

		cout << "delete 10\n";
		tree.remove(10);

		tree.Order(MidOrder);
	}

	return 0;
}